import {createSlice, PayloadAction} from "@reduxjs/toolkit";

export interface userState {
    username: string,
    nickname: string
}

const InitialState: userState = {nickname: '', username: ''}
const userSlice = createSlice({
    name: 'user',
    initialState: InitialState,
    reducers: {
        loginReducer(state: userState, action: PayloadAction<userState>) {
            return action.payload
        },
        loginOutReducer() {
            return InitialState
        }
    }
})
export default userSlice.reducer
export const {loginReducer, loginOutReducer} = userSlice.actions
